/**
 * DataDictController
 *
 * @description :: Server-side logic for managing Datadicts
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {

  initData: function (req, res) {
    DictInitService.initData(function (err) {
      res.ok();
    })
  },

  typeList: function (req, res) {
    var type = req.param('type');
    DataDict.find({
      where: {dictType: type, isUsing: true},
      sort: 'sortNum DESC'
    }).exec(function (err, list) {
      res.ok(list);
    });
  },

  disable: function (req, res) {
    id = req.param('id')
    DataDict.update({id: id}, {isUsing: false}).exec(function (err, updated) {
      if (err) {
        return res.json({
          code: 500
        });
      }
      return res.json({
        code: 200
      })
    });
  }

};

